package StructuralPattern.Facade;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class FileReader {
    public String read(String fileNameSrc) {
        System.out.print("读取文件，获取明文");
        StringBuffer stringBuffer = new StringBuffer();
        try {
            FileInputStream inputStream = new FileInputStream(fileNameSrc);
            int data;
            while ((data = inputStream.read()) != -1) {
                stringBuffer = stringBuffer.append((char)data);
            }
            inputStream.close();
            System.out.println(stringBuffer.toString());
        } catch (FileNotFoundException e) {
            System.out.println("文件不存在");
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println("文件操作错误");
            e.printStackTrace();
        }
        return stringBuffer.toString();
    }
}
